package quick.portal.service;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.message.BasicNameValuePair;

import quick.common.AppContext;
import quick.communication.AsyncHttpResponseHandler;
import quick.communication.HttpClient;
import quick.communication.RequestParams;

public class UserInfoService extends BaseService {

	public void login(String username,String password,AsyncHttpResponseHandler handler)
	{
		List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
		
        if (!(username==null || username=="")) {
        	params.add(new BasicNameValuePair("Username", username));
        }
        if (!(password==null || password=="")) {
        	params.add(new BasicNameValuePair("Password", password));
        }
  
        HttpClient.get(api_url+"Login", params, handler);

	}
	
	public void login(String token,AsyncHttpResponseHandler handler)
	{
		List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
		
		params.add(new BasicNameValuePair(AppContext.Login_Token_Key, token));
  
        HttpClient.get(api_url+"Login", params, handler);

	}
	
	public void modifyPassword(String newPassword,AsyncHttpResponseHandler handler)
	{
		RequestParams params = this.getParams().AddParam("NewPassword", newPassword);
		
		HttpClient.get(api_url+"ModifyPassword", params, handler);
	}

}
